home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-15 | 8.0 KB | 259 lines | [TEXT/ALFA] |
- #############################################################################
- # Install the files that support one of the LaTeX modes.
- # The global flag $latexVersion indicates which mode (LaTeX 2.09 or LaTeX2e)
- # is currently installed.
- #
- # Author: Tom Pollard <pollard@cucbs.chem.columbia.edu>
- # (updated 4/29/95 for latex.tcl v2.4)
- # (updated 7/02/96 for latex.tcl v3.2 TRS)
- #
- proc loadLaTeX {} {
- global HOME latexVersion
-
- set oldWd [pwd]
- cd $HOME
-
- set latex209Dir ":LaTeX:latex 2.09"
- set latex209Files {
- {"latexMode.tcl" ":Tcl:Modes" 1}
- {"latex.tcl" ":Tcl:Modes" 1}
- {"smart.tcl" ":Tcl:Modes" 0}
- {"LaTeX Help" ":Help" 0}
- {"LaTeX Key Bindings" ":Help" 0}
- }
-
- set latex2eDir ":LaTeX:latex 2e"
- set latex2eFiles {
- {"latexMode.tcl" ":Tcl:Modes" 1}
- {"latex.tcl" ":Tcl:Modes" 1}
- {"latexComm.tcl" ":Tcl:Modes" 0}
- {"latexEngine.tcl" ":Tcl:Modes" 0}
- {"latexFilesets.tcl" ":Tcl:Modes" 0}
- {"latexKeys.tcl" ":Tcl:Modes" 0}
- {"latexMacros.tcl" ":Tcl:Modes" 0}
- {"latexMenu.tcl" ":Tcl:Modes" 0}
- {"latexPatches.tcl" ":Tcl:Modes" 0}
- {"latexSmart.tcl" ":Tcl:Modes" 0}
- {"LaTeX Help" ":Help" 0}
- }
- set report 0
-
- if {$latexVersion == "2e"} {
- if {[askyesno "Install LaTeX 2.09?"] == "yes"} {
- set report [installFiles $latex209Dir $latex209Files $latex2eDir $latex2eFiles 0 1 TeX]
- if {$report != 0} {
- # uncomment these lines if new files are not automatically sourced
- # alertnote "Now quit and restart Alpha to load LaTeX 2.09 mode"
- # set latexVersion "2.09"
- # and comment out this one
- alertnote "LaTeX 2.09 support was successfully installed"
- #
- } else {
- alertnote "The installation was cancelled"
- }
- }
- } elseif {$latexVersion == "2.09"} {
- if {[askyesno "Install LaTeX 2e?"] == "yes"} {
- set report [installFiles $latex2eDir $latex2eFiles $latex209Dir $latex209Files 0 1 TeX]
- if {$report != 0} {
- # uncomment these lines if new files are not automatically sourced
- # alertnote "Now quit and restart Alpha to load LaTeX2e mode"
- # set latexVersion "2e"
- # and comment out this one
- alertnote "LaTeX2e support was successfully installed"
- #
- } else {
- alertnote "The installation was cancelled"
- }
- }
- }
-
- if {$report != 0} {
- set timePat {([0-9/]+) ([^:]+):([^:]+):([^:]+) (..)}
- regsub $timePat [join [mtime [now] short]] {¥1 ¥2.¥3¥5} timestamp
- set fname "$HOME:LaTeX:Install Report $timestamp"
-
- set tmpfid [open $fname "w+"]
- puts $tmpfid $report
- close $tmpfid
- }
-
- cd $oldWd
- }
-
- ##############################################################################
- # Install a list of files from $InstallDir into various destination folders.
- #
- # Each item of $installList contains a list of two items : a file and its
- # destination directory. If $backupDir and $backupList are given, then the
- # files from this list are first removed from the indicated directories and
- # saved in $backupDir. If $deleteOld is 1, then an old file is just
- # deleted if the backup directory doesn't exist or if it already contains
- # the file; if $overwriteBackups is 1, then old backup files will be
- # overwritten ($deleteOld is checked before $overwriteBackups).
- #
- # If any Tcl source files (.tcl) are installed, then they are also automatically
- # sourced and "rebuildTclIndices" is called to update the autoloader index files.
- #
- # Author: Tom Pollard <pollard@cucbs.chem.columbia.edu>
- #
- # if {[file extension $file] == ".tcl"} {
-
- proc installFiles {installDir installList backupDir backupList
- {deleteOld 0} {overwriteBackups 0} {deleteBindings 0}} {
- global HOME latexMenu
- set script {}
- set report ""
- set askedAlready 0
- set removed {}
-
- set script2 {}
- set report2 ""
-
- lappend script [list uplevel {#0} [list catch [list removeMenu $latexMenu]]]
-
- if {! [file exists $backupDir] && ! $deleteOld} {
- lappend script [list mkdir $backupDir]
- append report "Created backup directory ¥"$backupDir¥"¥n"
- }
-
- foreach item $backupList {
- set file [lindex $item 0]
- set dir [lindex $item 1]
-
- set frompath ${dir}:${file}
- set topath ${backupDir}:${file}
-
- if {[closeInstallFile $file] == "cancel"} {
- return 0
- }
-
- if {[file exists $frompath]} {
- if {[file exists $topath]} {
- if {!$deleteOld && !$overwriteBackups && !$askedAlready} {
- if {[askyesno "Can I delete old files that are already backed up?"] == "yes"} {
- set deleteOld 1
- } elseif {[askyesno "Can I overwrite previous backup files?"] == "yes"} {
- set overwriteBackups 1
- }
- set askedAlready 1
- }
- if {$deleteOld} {
- lappend script [list removeFile $frompath]
- append report "Deleted old file ¥"$file¥" from folder ¥"$dir¥"¥n"
- lappend removed $frompath
-
- } elseif {$overwriteBackups} {
- lappend script [list removeFile $topath]
- lappend script [list copyFile $frompath $topath]
- lappend script [list removeFile $frompath]
- append report "Saved old file ¥"$file¥" in folder ¥"$backupDir¥"¥n"
- lappend removed $frompath
-
- } else {
- message "No files were moved or deleted"
- return 0
- }
- } else {
- lappend script [list copyFile $frompath $topath]
- lappend script [list removeFile $frompath]
- append report "Saved old file ¥"$file¥" in folder ¥"$backupDir¥"¥n"
- lappend removed $frompath
- }
- } else {
- append report "-- old file ¥"$file¥" was missing from folder ¥"$dir¥" --¥n"
- }
- }
-
- append report "¥n"
-
- foreach item $installList {
- set file [lindex $item 0]
- set dir [lindex $item 1]
- set loadable [lindex $item 2]
- set frompath ${installDir}:${file}
- set topath ${dir}:${file}
-
- if {[closeInstallFile $file] == "cancel"} {
- return 0
- }
-
- if {[file exists $frompath]} {
- if {[file exists $topath] && [lsearch -exact $removed $topath] < 0} {
- if {[askyesno "Can I overwrite the old copy of $file?"] == "yes"} {
- lappend script [list removeFile $topath]
- append report "Deleted old file ¥"$file¥" in folder ¥"$dir¥"¥n"
- lappend removed $topath
- } else {
- return 0
- }
- }
- lappend script [list copyFile $frompath $topath]
- append report "Copied file ¥"$file¥" from folder ¥"$installDir¥" to ¥"$dir¥"¥n"
-
- if { $loadable } {
- lappend script2 [list uplevel {#0} [list source ${HOME}$topath]]
- append report2 "Loaded the new file ¥"$file¥"¥n"
- }
- } else {
- message "Installation aborted - no files were moved or deleted"
- alertnote "Install file ¥"$file¥" is missing"
- return 0
- }
- }
-
- if {[llength $script2]} {
- # comment out these lines to stop automatic sourcing of newly loaded .tcl files
- # (_Don't_ change the lines creating $script2, above)
- # if {$deleteBindings != 0} {
- # lappend script [list deleteModeBindings $deleteBindings]
- # append report "¥nRemoved the old ${deleteBindings}-mode key bindings¥n"
- # }
- set script [concat $script $script2]
- append report "¥n"
- append report $report2
-
- lappend script [list message "Rebuilding Filesets menuノ"]
- lappend script rebuildAllFilesets
- append report "¥nRebuilt Filesets menu"
-
- lappend script [list message "Rebuilding Tcl indicesノ"]
- lappend script rebuildTclIndices
- append report "¥nRebuilt Tcl indices¥n"
- }
-
- # # Uncomment these lines to get a play-by-play of the installation procedure
- # #
- # new -n "* Install Script *"
- foreach item $script {
- # insertText "$item¥n"
- eval $item
- }
- # catch {shrinkWindow 1}
- # setWinInfo dirty 0
-
- new -n "* Installation Report *"
- insertText $report "¥rYou must now REBOOT ALPHA.¥r"
- catch {shrinkWindow 1}
- setWinInfo dirty 0
- setWinInfo read-only 1
-
- return $report
- }
-
- proc closeInstallFile {file} {
- if {[lsearch -exact [winNames] $file] >= 0} {
- set reply [askyesno -c "Close file $file before installing?"]
- if {$reply == "yes"} {
- bringToFront $file
- killWindow
- }
- if {$reply == "cancel" ||
- ($reply == "yes" && [lsearch -exact [winNames] $file] >= 0)} {
- message "No files were moved or deleted"
- return "cancel"
- }
- }
- return ""
- }
-